home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 March / maximum-cd-2000-03.iso / Quake3 Game Source / Q3AGameSource.exe / Main / ui_ingame.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-18  |  9.3 KB  |  329 lines

  1. // Copyright (C) 1999-2000 Id Software, Inc.
  2. //
  3. /*
  4. =======================================================================
  5.  
  6. INGAME MENU
  7.  
  8. =======================================================================
  9. */
  10.  
  11.  
  12. #include "ui_local.h"
  13.  
  14.  
  15. #define INGAME_FRAME                    "menu/art/addbotframe"
  16. //#define INGAME_FRAME                    "menu/art/cut_frame"
  17. #define INGAME_MENU_VERTICAL_SPACING    28
  18.  
  19. #define ID_TEAM                    10
  20. #define ID_ADDBOTS                11
  21. #define ID_REMOVEBOTS            12
  22. #define ID_SETUP                13
  23. #define ID_SERVERINFO            14
  24. #define ID_LEAVEARENA            15
  25. #define ID_RESTART                16
  26. #define ID_QUIT                    17
  27. #define ID_RESUME                18
  28. #define ID_TEAMORDERS            19
  29.  
  30.  
  31. typedef struct {
  32.     menuframework_s    menu;
  33.  
  34.     menubitmap_s    frame;
  35.     menutext_s        team;
  36.     menutext_s        setup;
  37.     menutext_s        server;
  38.     menutext_s        leave;
  39.     menutext_s        restart;
  40.     menutext_s        addbots;
  41.     menutext_s        removebots;
  42.     menutext_s        teamorders;
  43.     menutext_s        quit;
  44.     menutext_s        resume;
  45. } ingamemenu_t;
  46.  
  47. static ingamemenu_t    s_ingame;
  48.  
  49.  
  50. /*
  51. =================
  52. InGame_RestartAction
  53. =================
  54. */
  55. static void InGame_RestartAction( qboolean result ) {
  56.     if( !result ) {
  57.         return;
  58.     }
  59.  
  60.     UI_PopMenu();
  61.     trap_Cmd_ExecuteText( EXEC_APPEND, "map_restart 0\n" );
  62. }
  63.  
  64.  
  65. /*
  66. =================
  67. InGame_QuitAction
  68. =================
  69. */
  70. static void InGame_QuitAction( qboolean result ) {
  71.     if( !result ) {
  72.         return;
  73.     }
  74.     UI_PopMenu();
  75.     UI_CreditMenu();
  76. }
  77.  
  78.  
  79. /*
  80. =================
  81. InGame_Event
  82. =================
  83. */
  84. void InGame_Event( void *ptr, int notification ) {
  85.     if( notification != QM_ACTIVATED ) {
  86.         return;
  87.     }
  88.  
  89.     switch( ((menucommon_s*)ptr)->id ) {
  90.     case ID_TEAM:
  91.         UI_TeamMainMenu();
  92.         break;
  93.  
  94.     case ID_SETUP:
  95.         UI_SetupMenu();
  96.         break;
  97.  
  98.     case ID_LEAVEARENA:
  99.         trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
  100.         break;
  101.  
  102.     case ID_RESTART:
  103.         UI_ConfirmMenu( "RESTART ARENA?", NULL, InGame_RestartAction );
  104.         break;
  105.  
  106.     case ID_QUIT:
  107.         UI_ConfirmMenu( "EXIT GAME?", NULL, InGame_QuitAction );
  108.         break;
  109.  
  110.     case ID_SERVERINFO:
  111.         UI_ServerInfoMenu();
  112.         break;
  113.  
  114.     case ID_ADDBOTS:
  115.         UI_AddBotsMenu();
  116.         break;
  117.  
  118.     case ID_REMOVEBOTS:
  119.         UI_RemoveBotsMenu();
  120.         break;
  121.  
  122.     case ID_TEAMORDERS:
  123.         UI_TeamOrdersMenu();
  124.         break;
  125.  
  126.     case ID_RESUME:
  127.         UI_PopMenu();
  128.         break;
  129.     }
  130. }
  131.  
  132.  
  133. /*
  134. =================
  135. InGame_MenuInit
  136. =================
  137. */
  138. void InGame_MenuInit( void ) {
  139.     int        y;
  140.     uiClientState_t    cs;
  141.     char    info[MAX_INFO_STRING];
  142.     int        team;
  143.  
  144.     memset( &s_ingame, 0 ,sizeof(ingamemenu_t) );
  145.  
  146.     InGame_Cache();
  147.  
  148.     s_ingame.menu.wrapAround = qtrue;
  149.     s_ingame.menu.fullscreen = qfalse;
  150.  
  151.     s_ingame.frame.generic.type            = MTYPE_BITMAP;
  152.     s_ingame.frame.generic.flags        = QMF_INACTIVE;
  153.     s_ingame.frame.generic.name            = INGAME_FRAME;
  154.     s_ingame.frame.generic.x            = 320-233;//142;
  155.     s_ingame.frame.generic.y            = 240-166;//118;
  156.     s_ingame.frame.width                = 466;//359;
  157.     s_ingame.frame.height                = 332;//256;
  158.  
  159.     y = 96;
  160.     s_ingame.team.generic.type            = MTYPE_PTEXT;
  161.     s_ingame.team.generic.flags            = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  162.     s_ingame.team.generic.x                = 320;
  163.     s_ingame.team.generic.y                = y;
  164.     s_ingame.team.generic.id            = ID_TEAM;
  165.     s_ingame.team.generic.callback        = InGame_Event; 
  166.     s_ingame.team.string                = "TEAM";
  167.     s_ingame.team.color                    = color_red;
  168.     s_ingame.team.style                    = UI_CENTER|UI_SMALLFONT;
  169.  
  170.     y += INGAME_MENU_VERTICAL_SPACING;
  171.     s_ingame.addbots.generic.type        = MTYPE_PTEXT;
  172.     s_ingame.addbots.generic.flags        = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  173.     s_ingame.addbots.generic.x            = 320;
  174.     s_ingame.addbots.generic.y            = y;
  175.     s_ingame.addbots.generic.id            = ID_ADDBOTS;
  176.     s_ingame.addbots.generic.callback    = InGame_Event; 
  177.     s_ingame.addbots.string                = "ADD BOTS";
  178.     s_ingame.addbots.color                = color_red;
  179.     s_ingame.addbots.style                = UI_CENTER|UI_SMALLFONT;
  180.     if( !trap_Cvar_VariableValue( "sv_running" ) || !trap_Cvar_VariableValue( "bot_enable" ) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER)) {
  181.         s_ingame.addbots.generic.flags |= QMF_GRAYED;
  182.     }
  183.  
  184.     y += INGAME_MENU_VERTICAL_SPACING;
  185.     s_ingame.removebots.generic.type        = MTYPE_PTEXT;
  186.     s_ingame.removebots.generic.flags        = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  187.     s_ingame.removebots.generic.x            = 320;
  188.     s_ingame.removebots.generic.y            = y;
  189.     s_ingame.removebots.generic.id            = ID_REMOVEBOTS;
  190.     s_ingame.removebots.generic.callback    = InGame_Event; 
  191.     s_ingame.removebots.string                = "REMOVE BOTS";
  192.     s_ingame.removebots.color                = color_red;
  193.     s_ingame.removebots.style                = UI_CENTER|UI_SMALLFONT;
  194.     if( !trap_Cvar_VariableValue( "sv_running" ) || !trap_Cvar_VariableValue( "bot_enable" ) || (trap_Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER)) {
  195.         s_ingame.removebots.generic.flags |= QMF_GRAYED;
  196.     }
  197.  
  198.     y += INGAME_MENU_VERTICAL_SPACING;
  199.     s_ingame.teamorders.generic.type        = MTYPE_PTEXT;
  200.     s_ingame.teamorders.generic.flags        = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  201.     s_ingame.teamorders.generic.x            = 320;
  202.     s_ingame.teamorders.generic.y            = y;
  203.     s_ingame.teamorders.generic.id            = ID_TEAMORDERS;
  204.     s_ingame.teamorders.generic.callback    = InGame_Event; 
  205.     s_ingame.teamorders.string                = "TEAM ORDERS";
  206.     s_ingame.teamorders.color                = color_red;
  207.     s_ingame.teamorders.style                = UI_CENTER|UI_SMALLFONT;
  208.     if( !(trap_Cvar_VariableValue( "g_gametype" ) >= GT_TEAM) ) {
  209.         s_ingame.teamorders.generic.flags |= QMF_GRAYED;
  210.     }
  211.     else {
  212.         trap_GetClientState( &cs );
  213.         trap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING );
  214.         team = atoi( Info_ValueForKey( info, "t" ) );
  215.         if( team == TEAM_SPECTATOR ) {
  216.             s_ingame.teamorders.generic.flags |= QMF_GRAYED;
  217.         }
  218.     }
  219.  
  220.     y += INGAME_MENU_VERTICAL_SPACING;
  221.     s_ingame.setup.generic.type            = MTYPE_PTEXT;
  222.     s_ingame.setup.generic.flags        = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  223.     s_ingame.setup.generic.x            = 320;
  224.     s_ingame.setup.generic.y            = y;
  225.     s_ingame.setup.generic.id            = ID_SETUP;
  226.     s_ingame.setup.generic.callback        = InGame_Event; 
  227.     s_ingame.setup.string                = "SETUP";
  228.     s_ingame.setup.color                = color_red;
  229.     s_ingame.setup.style                = UI_CENTER|UI_SMALLFONT;
  230.  
  231.     y += INGAME_MENU_VERTICAL_SPACING;
  232.     s_ingame.server.generic.type        = MTYPE_PTEXT;
  233.     s_ingame.server.generic.flags        = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  234.     s_ingame.server.generic.x            = 320;
  235.     s_ingame.server.generic.y            = y;
  236.     s_ingame.server.generic.id            = ID_SERVERINFO;
  237.     s_ingame.server.generic.callback    = InGame_Event; 
  238.     s_ingame.server.string                = "SERVER INFO";
  239.     s_ingame.server.color                = color_red;
  240.     s_ingame.server.style                = UI_CENTER|UI_SMALLFONT;
  241.  
  242.     y += INGAME_MENU_VERTICAL_SPACING;
  243.     s_ingame.restart.generic.type        = MTYPE_PTEXT;
  244.     s_ingame.restart.generic.flags        = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  245.     s_ingame.restart.generic.x            = 320;
  246.     s_ingame.restart.generic.y            = y;
  247.     s_ingame.restart.generic.id            = ID_RESTART;
  248.     s_ingame.restart.generic.callback    = InGame_Event; 
  249.     s_ingame.restart.string                = "RESTART ARENA";
  250.     s_ingame.restart.color                = color_red;
  251.     s_ingame.restart.style                = UI_CENTER|UI_SMALLFONT;
  252.     if( !trap_Cvar_VariableValue( "sv_running" ) ) {
  253.         s_ingame.restart.generic.flags |= QMF_GRAYED;
  254.     }
  255.  
  256.     y += INGAME_MENU_VERTICAL_SPACING;
  257.     s_ingame.resume.generic.type            = MTYPE_PTEXT;
  258.     s_ingame.resume.generic.flags            = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  259.     s_ingame.resume.generic.x                = 320;
  260.     s_ingame.resume.generic.y                = y;
  261.     s_ingame.resume.generic.id                = ID_RESUME;
  262.     s_ingame.resume.generic.callback        = InGame_Event; 
  263.     s_ingame.resume.string                    = "RESUME GAME";
  264.     s_ingame.resume.color                    = color_red;
  265.     s_ingame.resume.style                    = UI_CENTER|UI_SMALLFONT;
  266.  
  267.     y += INGAME_MENU_VERTICAL_SPACING;
  268.     s_ingame.leave.generic.type            = MTYPE_PTEXT;
  269.     s_ingame.leave.generic.flags        = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  270.     s_ingame.leave.generic.x            = 320;
  271.     s_ingame.leave.generic.y            = y;
  272.     s_ingame.leave.generic.id            = ID_LEAVEARENA;
  273.     s_ingame.leave.generic.callback        = InGame_Event; 
  274.     s_ingame.leave.string                = "LEAVE ARENA";
  275.     s_ingame.leave.color                = color_red;
  276.     s_ingame.leave.style                = UI_CENTER|UI_SMALLFONT;
  277.  
  278.     y += INGAME_MENU_VERTICAL_SPACING;
  279.     s_ingame.quit.generic.type            = MTYPE_PTEXT;
  280.     s_ingame.quit.generic.flags            = QMF_CENTER_JUSTIFY|QMF_PULSEIFFOCUS;
  281.     s_ingame.quit.generic.x                = 320;
  282.     s_ingame.quit.generic.y                = y;
  283.     s_ingame.quit.generic.id            = ID_QUIT;
  284.     s_ingame.quit.generic.callback        = InGame_Event; 
  285.     s_ingame.quit.string                = "EXIT GAME";
  286.     s_ingame.quit.color                    = color_red;
  287.     s_ingame.quit.style                    = UI_CENTER|UI_SMALLFONT;
  288.  
  289.     Menu_AddItem( &s_ingame.menu, &s_ingame.frame );
  290.     Menu_AddItem( &s_ingame.menu, &s_ingame.team );
  291.     Menu_AddItem( &s_ingame.menu, &s_ingame.addbots );
  292.     Menu_AddItem( &s_ingame.menu, &s_ingame.removebots );
  293.     Menu_AddItem( &s_ingame.menu, &s_ingame.teamorders );
  294.     Menu_AddItem( &s_ingame.menu, &s_ingame.setup );
  295.     Menu_AddItem( &s_ingame.menu, &s_ingame.server );
  296.     Menu_AddItem( &s_ingame.menu, &s_ingame.restart );
  297.     Menu_AddItem( &s_ingame.menu, &s_ingame.resume );
  298.     Menu_AddItem( &s_ingame.menu, &s_ingame.leave );
  299.     Menu_AddItem( &s_ingame.menu, &s_ingame.quit );
  300. }
  301.  
  302.  
  303. /*
  304. =================
  305. InGame_Cache
  306. =================
  307. */
  308. void InGame_Cache( void ) {
  309.     trap_R_RegisterShaderNoMip( INGAME_FRAME );
  310. }
  311.  
  312.  
  313. /*
  314. =================
  315. UI_InGameMenu
  316. =================
  317. */
  318. void UI_InGameMenu( void ) {
  319.     // force as top level menu
  320.     uis.menusp = 0;  
  321.  
  322.     // set menu cursor to a nice location
  323.     uis.cursorx = 319;
  324.     uis.cursory = 80;
  325.  
  326.     InGame_MenuInit();
  327.     UI_PushMenu( &s_ingame.menu );
  328. }
  329.